<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<title>fangbing</title>
<link href="/res/css/bootstrap.css" rel="stylesheet">
<link href="/res/css/metisMenu.css" rel="stylesheet">
<link href="/res/css/fullcalendar.css" rel="stylesheet">
<link href="/res/css/jquery-ui.css" rel="stylesheet">
<link href="/res/css/sb-admin-2.css" rel="stylesheet">
<link href="/res/css/font-awesome.css" rel="stylesheet">

<script src="/res/js/moment.js"></script>
<script src="/res/js/jquery-2.1.4.js"></script>
<script src="/res/js/bootstrap.js"></script>
<script src="/res/js/jquery-ui.js"></script>
<script src="/res/js/fullcalendar.js"></script>
<script src="/res/js/metisMenu.js"></script>
<script src="/res/js/sb-admin-2.js"></script>
<script src="/res/js/jquery.twbsPagination.js"></script>

</head>
<body>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default panel-success">
				<div class="panel-heading">
					<h1>
						用户信息 <small>用户信息查询</small>
					</h1>
				</div>
				<div class="panel-body">
					<div>
						<div>
							<div class="row">
								<form class="form-inline" id="searchForm" method="post">
									<div class="form-group">
										<label for="userName">用户名称</label> <input type="text"
											class="form-control" id="userName" name="userName">
									</div>
									<button class="btn btn-default" id="search">查询</button>
									<input class="btn btn-default" type="button" id="add"
										value="新增" />
								</form>
								<hr>
							</div>
							<div class="row">
								<div class="col-sm-12">
									<table class="table table-bordered table-striped">
										<tr>
											<th style="width: 50px;text-align:center;">用户ID</th>
											<th style="width: 200px;text-align:center;">用户名称</th>
											<th style="width: 100px;text-align:center;">操作</th>
										</tr>
										<tbody>
											<c:forEach items="${page.listResult}" var="item">
												<tr>
													<td>${item.id}</td>
													<td>${item.userName}</td>
													<td><input type="button" class="btn btn-default"
														id="update" onclick="update(${item.id});" value="修改" /> 
														<input type="button" class="btn btn-default" id="delete"
														onclick="deleteUser(${item.id});" value="删除" /></td>
												</tr>
											</c:forEach>
										</tbody>
									</table>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<ul id="pagination" class="pagination-sm"></ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
<script>
	var totalPages;
	if (${page.pageBean.totalPage} == 0) {
		totalPages = 1;
	} else {
		totalPages = ${page.pageBean.totalPage};
	}
	$('#pagination').twbsPagination(
			{
				totalPages : totalPages,
				startPage : ${page.pageBean.pageNo},
				onPageClick : function(event, page) {
					$("#searchForm").attr("action",
							"/user/searchUserList.do?pageNo=" + page);
					$("#searchForm").submit();
				}
			});
	//新增用户信息
	$("#add").click(function() {
		window.location.href = "/user/toAddOrUpdate.do";
	});

	//修改用户信息
	function update(id) {
		window.location.href = "/user/toAddOrUpdate.do?id=" + id;
	}
	
	//修改用户信息
	function deleteUser(id) {
		alert("删除成功！");
		window.location.href = "/user/delete.do?id=" + id;
		
	}
</script>
</html>
